Skip to content

Conversation

@reformstudios
Copy link

The existing regex patterns only handle either removing the version number from a non-sequence path or the frame-number from a sequence path, not both together (removing the version and converting the frame number to padding).
This update adds a new regex pattern that should(I'm a regex novice) allow removal of version number from a sequence and conversion of framenumber to padding.

The existing regex patterns only handle either removing the version number from a non-sequence path or the frame-number from a sequence path, not both together (removing the version and converting the frame number to padding).
This update adds a new regex pattern that should(I'm a regex novice) allow removal of version number from a sequence and conversion of framenumber to padding.
Copy link
Contributor

@josh-t josh-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @reformstudios! Thanks for the PR! I definitely see the need for this. I've added some comments for you. Let me know what you think. Thanks!!

@@ -1,3 +1,7 @@
'''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

guessing this was left by accident?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed.


# a regular expression used to extract the frame number from the file.
# this implementation assumes the version number is of the form '.####'
# this implementation assumes the frame number is of the form '.####'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch! my cut and paste error.

# or '-'.
FRAME_REGEX = re.compile("(.*)([._-])(\d+)\.([^.]+)$", re.IGNORECASE)

# a regular expression used to extrand the frame number AND version from the file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: extrand => extract

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

"""

def get_publish_name(self, path, sequence=False):
def get_publish_name(self, path, sequence=False, version=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest making the new arg strip_frame=False or something like that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, my suggestion is ambiguous... but do you mean 'strip_version' in this case?... because currently, with sequence = False, the version is removed, but if sequence=True, then the version remains. So we need both strip_version and strip_frame I think... and to cover all bases you might as well add a strip_ext option too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference here would be to include the most common behaviors, keeping the interface fairly clean. Now that I'm looking at this again, maybe we should have just done something like this from the start:

  • if this is a sequence, remove the frame number
  • try to remove any version number (acting on the result of ^ if applicable)

Maybe that would be sufficient and keep things simple (for most cases) and consistent. Anything beyond that would imply taking over the hook. Curious what you think.


version_pattern_match = re.search(VERSION_REGEX, filename)
frame_pattern_match = re.search(FRAME_REGEX, filename)
version_frame_pattern_match = re.search(VERSION_FRAME_REGEX, filename)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't need the additional regex? Can we make this a 2-pass process if the additional arg is supplied?

if the assumption is that the frame number is always after the version number (when both are included) maybe the logic should be:

if strip_frame and frame_pattern_match:
    # remove the frame number with the existing frame regex

# continue with the existing logic...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is the best approach. I did consider that this might be possible, but in the end went with the simple option of formulating a specific regex.

extension = frame_pattern_match.group(4) or ""
publish_name = "%s%s%s.%s" % (
prefix, frame_sep, display_str, extension)
elif version_frame_pattern_match and sequence and version:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments above.

@reformstudios
Copy link
Author

reformstudios commented Apr 11, 2018 via email

@manneohrstrom manneohrstrom added the Logged Logged in Jira label Jul 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Logged Logged in Jira

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants